﻿using System;
using System.Collections.Generic;
using System.Text;
using OA .Model;
using OA.Manager;
namespace OA.Bll
{
   public class DeptPresenter
    {
       public string  GetAllDept()
       {
           DeptManager manager = new DeptManager();
           List<DeptInfo> depts = manager.GetAllDept();
           StringBuilder stringBuilder = new StringBuilder();
           stringBuilder.Append("[");
           foreach (DeptInfo deptInfo in depts)
           {
               stringBuilder.Append("{");
               if (deptInfo != null)
                   stringBuilder.Append(string.Format("\"id\": \"{0}\", \"text\": \"{1}\"",
                                                      deptInfo.Id,
                                                      deptInfo.DeptName));
               stringBuilder.Append("},");
           }
           stringBuilder.Remove(stringBuilder.ToString().Length - 1, 1);
           stringBuilder.Append("]");
           return stringBuilder.ToString();
       }
    }
}
